package vista.modelo;

import modelo.Edge;
import modelo.Node;

public class VNode extends Node {

	public int x, y, radius;

	public VNode(String name, int x, int y, int radius) {
		super(name);
		this.x = x;
		this.y = y;
		this.radius = radius;
	}

	public void setPosition(int x, int y) {
		this.x = x;
		this.y = y;
		for (Edge edge : outgoingEdges)
			((VEdge)edge).moved = true;
		for (Edge edge : incomingEdges)
			((VEdge)edge).moved = true;
	}

	public void keepInMap(int maxWidth, int maxHeight) {
		if(x < 0)
			x = 0;
		else if(x > maxWidth)
			x = maxWidth;
		if(y < 0)
			y = 0;
		else if(y > maxHeight)
			y = maxHeight;
	}

	public Object clone() {
		VNode clone = new VNode(name+"", x, y, radius);
		clone.acceptor = acceptor;
		clone.consecutive = consecutive;
		return clone;
	}

}
